<?php
/**
 * Получение данных о пользователе по урл-адресу idsrv 
 *
 * @package default
 * @author Alexander Sibiryakov
 **/
class AggregatedModel_ItemProcessor_IdsrvUrlField extends AggregatedModel_ItemProcessor_Common implements AggregatedModel_ItemProcessor_Interface
{
	private $mm;
	
	public function __construct($rh) {
		$this->mm = $rh->ctx->mm;
	}
	
	public function processItem(array $data) {

		// platonica_id url
		$pid_user = NULL;
		if (is_numeric($data['author_url'])) {
			$pid_user = $this->mm->getModel("PlatonicaIDuser", "m")->getUser( $data['author_url'] );
		}
		
		if ($pid_user instanceof fobject) {
			preg_match_all("/([0-9]+) ([0-9]+) (http:\/\/[^а-бА-Б ]+)/", $pid_user->data["platonica.avatars"], $matches);

			$data['platonicaid_author']	= array (
				"name" => $pid_user->data["sreg.fullname"],
				"avatar_url" => $matches[3][1],
				"url" => $pid_user->data["platonica.profile_url"],
				);
		}

		return $data;
	}
} // END class
